package com.xjtu.platform.security.dao;

import com.xjtu.platform.security.dto.AdminLoginDto;
import com.xjtu.platform.security.dto.LoginDto;
import com.xjtu.platform.security.dto.NewPwdDto;
import com.xjtu.platform.security.entitiy.Info;
import com.xjtu.platform.security.entitiy.UserInfo;
import org.apache.ibatis.annotations.*;

@Mapper
public interface LoginDao {
    @Select("select count(reader_id) from reader where reader_code=#{dto.reader_code} and pwd=#{dto.pwd}")
    int checkLogin(@Param("dto") LoginDto loginDto);

    @Select("select reader_id from reader where reader_code = #{code}")
    String getReaderId(@Param("code") String readerCode);

    @Update("update reader set pwd = #{pwd.new_pwd} where reader_id = #{code}")
    void updatePwd(@Param("pwd") NewPwdDto newPwdDto, @Param("code") String readerId);

    @Select("select name,reader_code,phone from reader where reader_id = #{readerId}")
    Info getInfo(String readerId);

    @Select("select count(admin_id) from admin where admin_code=#{dto.admin_code} and pwd=#{dto.pwd}")
    int checkAdminLogin(@Param("dto") AdminLoginDto adminLoginDto);

    @Select("select admin_id from admin where admin_code = #{code}")
    String getAdminId(@Param("code") String admin_code);
}
